//------------------------------------------------------------------------------
// Fichiers d'ent�te utilis�s
//------------------------------------------------------------------------------
#include "BinaryImage.hpp"
#include <GL/gl.h>

//------------------------------------------------------------------------------
// Définition de constantes
//------------------------------------------------------------------------------
namespace ImageAnalysis
{

	//----------------------------------------------------------------------
	// Constructeur
	//----------------------------------------------------------------------
	BinaryImage::BinaryImage( int width, int height ):
	Image(width, height)
	{
		//allocation de la structure contenant les pixels
		pixels = new unsigned char [width*height];
		
		// Intialisation de tous les pixels �la valeur RESET_VALUE
		for( int pixelIndex=0; pixelIndex < width*height; ++pixelIndex)
		{
			pixels[pixelIndex] = BinaryImage::RESET_VALUE;
		}
	}

	//----------------------------------------------------------------------
	// Destructeur
	//----------------------------------------------------------------------
	BinaryImage::~BinaryImage( )
	{
		delete pixels;
	}

    //----------------------------------------------------------------------
	//
	//----------------------------------------------------------------------
	void BinaryImage::Draw( )
	{
        glDrawPixels( layerWidth, layerHeight, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixels );
	}

    //----------------------------------------------------------------------
	//
	//----------------------------------------------------------------------
	unsigned char* BinaryImage::GetPixel( int index )
	{
		return &pixels[index];
	}

    //----------------------------------------------------------------------
	//
	//----------------------------------------------------------------------
	void BinaryImage::SetPixel( int index, unsigned char* value )
	{
		pixels[index]=*value;
	}
}
